/**
 * This file is part of SourceCodeMetrics project.
 * 
 * Copyright (C) 2012 Krystian Warzocha
 *
 * SourceCodeMetrics is free software: you can redistribute it and/or modify it 
 * under the terms of the GNU General Public License as published by the 
 * Free Software Foundation, either version 2 of the License, or 
 * (at your option) any later version.
 * 
 * SourceCodeMetrics is distributed in the hope that it will be useful, but 
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 
 * more details.
 * 
 * You should have received a copy of the GNU General Public License along with 
 * SourceCodeMetrics. If not, see http://www.gnu.org/licenses/.
 */

package org.sourcecodemetrics.view.options;

import org.sourcecodemetrics.view.options.limitations.MetricConfigurations;

final class MetricsPanel extends javax.swing.JPanel {

    private final MetricsOptionsPanelController controller;

    MetricsPanel(MetricsOptionsPanelController controller) {
        this.controller = controller;
        initComponents();
        // TODO listen to changes in form fields and call controller.changed()
    }    

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        bindingGroup = new org.jdesktop.beansbinding.BindingGroup();

        metricConfigurationsBean = new org.sourcecodemetrics.view.options.MetricConfigurationsBean();
        lbDescription = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        tbMetricConfigurations = new javax.swing.JTable();

        org.openide.awt.Mnemonics.setLocalizedText(lbDescription, org.openide.util.NbBundle.getMessage(MetricsPanel.class, "MetricsPanel.lbDescription.text")); // NOI18N

        org.jdesktop.beansbinding.ELProperty eLProperty = org.jdesktop.beansbinding.ELProperty.create("${metricConfigurations}");
        org.jdesktop.swingbinding.JTableBinding jTableBinding = org.jdesktop.swingbinding.SwingBindings.createJTableBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, metricConfigurationsBean, eLProperty, tbMetricConfigurations, "");
        org.jdesktop.swingbinding.JTableBinding.ColumnBinding columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${symbol}"));
        columnBinding.setColumnName("Symbol");
        columnBinding.setEditable(false);
        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${name}"));
        columnBinding.setColumnName("Name");
        columnBinding.setColumnClass(String.class);
        columnBinding.setEditable(false);
        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${scope}"));
        columnBinding.setColumnName("Scope");
        columnBinding.setEditable(false);
        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${minimum}"));
        columnBinding.setColumnName("Minimum");
        columnBinding.setColumnClass(Double.class);
        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${maximum}"));
        columnBinding.setColumnName("Maximum");
        columnBinding.setColumnClass(Double.class);
        bindingGroup.addBinding(jTableBinding);
        jTableBinding.bind();
        jScrollPane1.setViewportView(tbMetricConfigurations);
        tbMetricConfigurations.getColumnModel().getColumn(0).setHeaderValue(org.openide.util.NbBundle.getMessage(MetricsPanel.class, "MetricsPanel.tbMetricConfigurations.columnModel.title0_1")); // NOI18N
        tbMetricConfigurations.getColumnModel().getColumn(1).setHeaderValue(org.openide.util.NbBundle.getMessage(MetricsPanel.class, "MetricsPanel.tbMetricConfigurations.columnModel.title3")); // NOI18N
        tbMetricConfigurations.getColumnModel().getColumn(2).setHeaderValue(org.openide.util.NbBundle.getMessage(MetricsPanel.class, "MetricsPanel.tbMetricConfigurations.columnModel.title4")); // NOI18N
        tbMetricConfigurations.getColumnModel().getColumn(3).setHeaderValue(org.openide.util.NbBundle.getMessage(MetricsPanel.class, "MetricsPanel.tbMetricConfigurations.columnModel.title1_1")); // NOI18N
        tbMetricConfigurations.getColumnModel().getColumn(4).setHeaderValue(org.openide.util.NbBundle.getMessage(MetricsPanel.class, "MetricsPanel.tbMetricConfigurations.columnModel.title2_1")); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 395, Short.MAX_VALUE)
                    .addComponent(lbDescription))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lbDescription)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 392, Short.MAX_VALUE)
                .addContainerGap())
        );

        bindingGroup.bind();
    }// </editor-fold>//GEN-END:initComponents

    void load() {
        MetricConfigurations.getMc().load();
    }

    void store() {
        MetricConfigurations.getMc().store();
    }

    boolean valid() {
        // TODO check whether form is consistent and complete
        return true;
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JLabel lbDescription;
    private org.sourcecodemetrics.view.options.MetricConfigurationsBean metricConfigurationsBean;
    private javax.swing.JTable tbMetricConfigurations;
    private org.jdesktop.beansbinding.BindingGroup bindingGroup;
    // End of variables declaration//GEN-END:variables
}
